home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T----------------------------------;
- ;Name: Directory List.
- ;Author: Paul Manias
- ;Copyright: DreamWorld Productions (c) 1996-1997. Freely distributable.
- ;
- ;This demo lists files and directories from "GMS:" in the IceBreaker window.
-
- INCDIR "INCLUDES:"
- INCLUDE "dpkernel/dpkernel.i"
- INCLUDE "files/segments.i"
- INCLUDE "system/debug.i"
-
- SECTION "Demo",CODE
-
- ;===========================================================================;
- ; INITIALISE DEMO
- ;===========================================================================;
-
- STARTDPK
-
- Start: MOVEM.L A0-A6/D1-D7,-(SP)
- move.l DPKBase(pc),a6
- lea DirTags(pc),a0 ;a0 = Directory tags.
- sub.l a1,a1
- CALL Init ;>> = Open the directory.
- tst.l d0
- beq.s .Exit
-
- move.l Directory(pc),a0 ;a0 = Directory Object.
- CALL Activate ;>> = Get a directory list.
-
- bsr.s PrintDirectory
-
- .Exit move.l Directory(pc),a0
- CALL Free
- MOVEM.L (SP)+,A0-A6/D1-D7
- moveq #ERR_OK,d0
- rts
-
- ;===========================================================================;
- ; PRINT DIRECTORY STRUCTURE
- ;===========================================================================;
-
- PrintDirectory:
- move.l Directory(pc),a0 ;a0 = Directory.
- move.l DIR_ChildDir(a0),a0 ;a0 = DirList.
- .dirlp cmp.l #$00,a0
- beq.s .filelist
- move.l DIR_Source(a0),a1 ;a1 = FileName.
- moveq #DBG_Message,d7 ;d7 = Message.
- move.l FN_Name(a1),a5 ;a5 = Name of file.
- CALL DebugMessage ;>> = Send the message.
- move.l DIR_Next(a0),a0 ;a0 = Next directory.
- bra.s .dirlp ;>> = Keep looping.
-
- .filelist
- move.l Directory(pc),a0 ;a0 = Directory.
- move.l DIR_ChildFile(a0),a0 ;a0 = DirList.
- .filelp cmp.l #$00,a0
- beq.s .end
- move.l FL_Source(a0),a1 ;a1 = FileName.
- moveq #DBG_Message,d7 ;d7 = Message.
- move.l FN_Name(a1),a5 ;a5 = Name of file.
- CALL DebugMessage ;>> = Send the message.
- move.l FL_Next(a0),a0 ;a0 = Next directory.
- bra.s .filelp ;>> = Keep looping.
- .end rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- DirTags: dc.l TAGS_DIRECTORY
- Directory: dc.l 0
- dc.l DIRA_Source,.dir
- dc.l TAGEND
-
- .dir FILENAME "GMS:"
-
- ;===========================================================================;
-
- ProgName: dc.b "Directory List",0
- ProgAuthor: dc.b "Paul Manias",0
- ProgDate: dc.b "10 December 1997",0
- ProgCopyright: dc.b "DreamWorld Productions (c) 1996-1997. Freely distributable.",0
- ProgShort: dc.b "Lists the files in a directory.",0
- even
-
-